package com.itheima.service.ipml;

import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.pojo.Emp;
import com.itheima.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    /**
     * 查询模版
     * @return
     */
    @Override
    public List<Dept> listdept() {
        return deptMapper.listdept();
    }

    /**
     * 删除部门
     */
    @Override
    public void deleteDept(Integer id) {
        deptMapper.deldteDept(id);
    }

    /**
     * 新增部门
     * @param dept
     */
    @Override
    public void insertDept(Dept dept) {
        //补全部门数据
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insertDept(dept);
    }

    /**
     * id查询
     *
     * @param id
     * @return
     */
    @Override
    public Dept listByid(Integer id) {
        return deptMapper.listByid(id);
    }

    /**
     * 修改数据
     * @param
     * @return
     */
    @Override
    public void updateDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }






}


